import  { useState, useEffect } from 'react';
import { loadModules } from '@esri/react-arcgis';

const GaodeLayer = (props) => {
    const [gaodeLayer, setGaodeLayer] = useState(null);
    useEffect(() => {
        loadModules(["dojo/_base/declare",
            "esri/geometry/Extent",
            "esri/SpatialReference",
            "esri/geometry/Point",
            "esri/layers/TileInfo",
            "esri/layers/TiledMapServiceLayer"]).then(([Extent, SpatialReference, Point, TileInfo, TiledMapServiceLayer]) => {
            
            const gaodeLayer = new TiledMapServiceLayer({
                
            });
            setGaodeLayer(gaodeLayer);
            props.map.add(gaodeLayer);
        }).catch((err) => console.error(err));

        return function cleanup() {
            props.map.remove(gaodeLayer);
        }
    }, [ props ]);

    return null;
}
export default GaodeLayer;